package com.yjsn.base.config;

import com.yjsn.base.interceptor.SignInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author: Liu Yang
 * @create: 2024-04-03 15:07
 * @Description:
 */
@Configuration
public class MvcInterceptorConfig extends WebMvcConfigurationSupport {
    @Autowired
    private SignInterceptor signInterceptor;

//    @Autowired
//    private LoginInterceptor loginInterceptor;

    /**
     * @Description 注册拦截器，声明要拦截的url
     * @author taoh
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 签名拦截
        registry.addInterceptor(signInterceptor)
                .addPathPatterns("/**");
//        registry.addInterceptor(loginInterceptor)
//                .addPathPatterns("/**")
//                 .excludePathPatterns("/user/login/**","/user/getPhoneNumber/**");
        super.addInterceptors(registry);
    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        super.addResourceHandlers(registry);
    }
}
